<template>
	<view >

		<web-view ref="webview" :webview-styles="webviewStyles" 
			:src="url" @message="getMessage"></web-view>
		
		
	</view>
</template>

<script>
	var sweixin;
	export default {
		data() {
			return {
				Bearer: '',
				pageHeight: '300rpx',
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				},
				url:""
				
			}
		},
		onLoad(opt) {
			let sysInfo = uni.getSystemInfoSync();
			let info = uni.getWindowInfo();
			console.log("sysInfo", sysInfo);
			this.pageTop = sysInfo.safeArea.top;
			console.log("pageTop", this.pageTop);
			this.pageHeight = info.windowHeight - this.pageTop;
			
			this.Bearer=uni.getStorageSync("Bearer");
			if(opt.url){
				this.url=opt.url;
			}
			//this.url="https://lgh5.boyaltd.cn/#/pages/pay/Payment?Bearer="+this.Bearer
			 // this.url="http://192.168.5.30:8081/#/pages/pay/Payment?Bearer="+this.Bearer
			// this.weixin();

		},
		onShow() {
			let t=new Date().getTime();
			//this.url="https://lgh5.boyaltd.cn/#/pages/switchPages/main?Bearer="+this.Bearer+"&t="+t;
			if(opt.url==""){
				this.url="http://192.168.101.6:8081/#/pages/switchPages/main?Bearer="+this.Bearer+"&t="+t;
			}else{
				
			}
			console.log("jf->show",t);
			
		},
		onReady() {
		// 	var currentWebview = this.$scope
		// .$getAppWebview(); //获取当前页面的webview对象,此对象相当于html5plus里的plus.webview.currentWebview()        
		// 	setTimeout(function() {
		// 		let webview = currentWebview.children()[0];
		// 		// let Bearer=uni.getStorageSync("Bearer");
		// 		// console.log("Bearer",Bearer);
		// 		// this.Bearer=Bearer;
		// 		//   let js=`uni.setStorageSync("Bearer","${Bearer}"); uni.showToast({	title: "${Bearer}",duration: 2000})`;
		// 		//                //webview.evalJS("window.localStorage.setItem('Bearer',''"+uni.getStorageSync("Bearer")+"');console.log('bearer')");  
		// 		// webview.evalJS(js); 

		// 		let Bearer = uni.getStorageSync("Bearer");
		// 		this.Bearer=Bearer;
		// 		webview.evalJS(`uni.$emit('Bearer',{Bearer:'${Bearer}'})`);

		// 	}, 500); //如果是页面初始化调用时，需要延时一下   
		},
		methods: {
			weixin() {
				// #ifdef APP-PLUS
				plus.share.getServices(function(s) {
					var shares = {};
					for (var i = 0; i < s.length; i++) {
						var t = s[i];
						console.log(t);
						shares[t.id] = t;
						console.log(t.id);
					}
					sweixin = shares['weixin'];
					console.log("微信服务列表：" + JSON.stringify(sweixin));
				}, function(e) {
					console.log("获取分享服务列表失败：" + e.message);
				});
				//#endif
			},
			getMessage(e) {
				let self=this;
				let dev=uni.getStorageSync("is_PreviewVer")
				if(dev){
					uni.showModal({
						title:"接收参数",
						content: JSON.stringify(e.detail),
						showCancel: false,
						success:function(){
							self.$comm.web_message(e);
						}
					})
				}else{
					this.$comm.web_message(e);
				}
				
		
			}
		}
	}
</script>

<style>
page{
	width: 100%;
	position: fixed;
	top: 0rpx;
	bottom: 0rpx;
	height: 100%;
	background-color: #ccc;
}
</style>